<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                template="../WEB-INF/facelets/layout.xhtml"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:c="http://java.sun.com/jsp/jstl/core">
    <ui:param name="title" value="camelBlog"/>
    <ui:param name="headerTitle" value="camelBlog"/>
    <h:outputStylesheet library="css" name="cssLayout.css" />
    <ui:define name="content">

        <h:form id="userTable">


            <p:dataTable var="user" value="#{adminControllerBean.users}">

                <p:column>
                    <f:facet name="header">
                        <h:outputText value="remove user"/>
                    </f:facet>
                    <p:commandButton value="Remove User" update="userTable"  actionListener="#{adminControllerBean.deleteUser}" >
                        <f:attribute name="user" value="#{user}" />
                    </p:commandButton>
                    
                </p:column>

                <p:column sortBy="#{user.userName}">
                    <f:facet name="header">
                        <h:outputText value="Name"/>
                    </f:facet>
                    <h:outputText value="#{user.userName}"/>
                </p:column>

                <p:column sortBy="#{user.userLevel}">
                    <f:facet name="header">
                        <h:outputText value="User level"/>
                    </f:facet>
                    <h:outputText value="#{user.userLevel}"/>
                </p:column>

                <p:column>
                    <p:menuButton value="Level" >  
                        <p:menuitem value="User" update="userTable"
                                    actionListener="#{adminControllerBean.setUser}">  
                            <f:attribute name="user" value="#{user}" />
                        </p:menuitem>
                        <p:menuitem value="Writer" update="userTable"
                                    actionListener="#{adminControllerBean.setWriter}">  
                            <f:attribute name="user" value="#{user}" />
                        </p:menuitem>
                        <p:menuitem value="Admin" update="userTable"
                                    actionListener="#{adminControllerBean.setAdmin}">  
                            <f:attribute name="user" value="#{user}" />
                        </p:menuitem>
                    </p:menuButton>  
                </p:column>

            </p:dataTable>
        </h:form>
    </ui:define>
</ui:composition>

